home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #2 / Monster Media No. 2 (Monster Media)(1994).ISO / fonts / uspsbc.zip / USPSBC.PRG < prev    next >
Text File  |  1994-04-12  |  4KB  |  126 lines

  1. * Program..: USPSBC.prg
  2. * Author...: Terry L. Johnson.
  3. * Telephone: (303) 352-8025
  4. * Date.....: 4/15/94.
  5. * Notice...: Copyright 1994,  Terry Johnson Consulting.
  6. * Notes....: To update a field withing a data base
  7. *   which contains the characters necessary to print a Bar code.
  8. *
  9. SET TALK OFF
  10. SET BELL OFF
  11. SET COLOR ON
  12. SET COLOR TO W+/B,W+/R,B
  13. SET INTENSITY ON
  14. * Initialize memory variables...
  15. STORE "zip      " + SPACE(20) TO i_zip
  16. STORE "zip4     " + SPACE(20) TO i_zip4
  17. STORE "dp       " + SPACE(20) TO i_dp
  18. STORE "BarCode  " TO o_bc
  19. SET STATUS OFF
  20. SET SCOREBOARD OFF
  21. SET PRINT OFF
  22. SET CONSOLE ON
  23. * Heading is displayed and parameters are entered...
  24. CLEAR GETS
  25. CLEAR
  26. @ 0,17  SAY "----------------------------------------------"
  27. @ 1,17  SAY "  General Zip Code - Bar Code Field Generation"
  28. @ 3,17  SAY "----------------------------------------------"
  29. @ 5,5   SAY "This screen requests the source FIELDS for calculation of the"
  30. @ 6,5   SAY "Postal Bar Code Print Field, The three fields needed are:"
  31. @ 7,5   SAY "  1) Postal Five digit ZIP code"
  32. @ 8,5   SAY "  2) Postal Four digit ZIP code extension"
  33. @ 9,5   SAY "  3) Postal Delivery Point (Two digit code)"
  34. @ 11,5  SAY "Output Field:";
  35.         GET o_bc PICTURE "@B! XXXXXXXXXX"
  36. @ 12,5  SAY "consists of the characters needed to print the US Postal Bar Code"
  37. @ 12,5  SAY "using the special TTF Font.  The Output Consists of 14 characters"
  38. @ 13,5  SAY "broken up in the following manner:"
  39. @ 15,5  SAY "      1 Character Start Character ([)"
  40. @ 16,5  SAY "      5 Characters Zip Code             ";
  41.         GET i_zip PICTURE  "@B! XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  42. @ 17,5  SAY "      4 Characters Zip + 4 Code         ";
  43.         GET i_zip4 PICTURE "@B! XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  44. @ 18,5  SAY "      2 Characters Delivery Point       ";
  45.         GET i_dp PICTURE   "@B! XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  46. @ 14,5  SAY "      1 Character Base 10 Check Digit"
  47. @ 14,5  SAY "      1 Character Trailing Character (])"
  48. READ
  49. CLEAR
  50. SET STATUS ON
  51. SET SCOREBOARD ON
  52. i_zip = TRIM(i_zip)
  53. IF LEN(i_zip) > 0
  54.   e_zip = .T.
  55. ELSE
  56.   e_zip = .F.
  57. ENDIF
  58. i_zip4 = TRIM(i_zip4)
  59. IF LEN(i_zip4) > 0
  60.   e_zip4 = .T.
  61. ELSE
  62.   e_zip4 = .F.
  63. ENDIF
  64. i_dp = TRIM(i_dp)
  65. IF LEN(i_dp) > 0
  66.   e_dp = .T.
  67. ELSE
  68.   e_dp = .F.
  69. ENDIF
  70. o_bc = TRIM(o_bc)
  71. IF LEN(o_bc) > 0
  72.   e_bc = .T.
  73. ELSE
  74.   e_bc = .F.
  75. ENDIF
  76. ******
  77. *   main loop *********************************************
  78. ******
  79. GO TOP
  80. DO WHILE .NOT. EOF()
  81.   STORE SPACE(14) TO b_code
  82. *******
  83. *  Process Bar Code if enough Information Present
  84. *******
  85.   IF e_zip .and. e_bc
  86.     STORE  LEFT(&i_zip,5) TO b_code
  87.     IF e_zip4
  88.       IF LEN(TRIM(LEFT(&i_zip4,4))) = 4
  89.         b_code = b_code + LEFT(&i_zip4,4)
  90.         IF e_dp
  91.           IF LEN(TRIM(LEFT(&i_dp,2))) = 2
  92.             b_code = b_code + LEFT(&i_dp,2)
  93.           ENDIF
  94.         ENDIF
  95.       ENDIF
  96.     ENDIF
  97.     STORE  LEN(b_code) TO lnb_code
  98.     STORE  .F. TO pb_code
  99.     IF lnb_code >= 5
  100.       STORE  .T. TO pb_code
  101.       STORE  0 TO dig_sum
  102.       STORE  0 TO lop_e
  103.       DO WHILE lop_e < lnb_code
  104.         lop_e = lop_e + 1
  105.         IF (SUBSTR(b_code,lop_e,1) < "0").or.(SUBSTR(b_code,lop_e,1) > "9")
  106.           pb_code = .F.
  107.         ELSE
  108.           dig_sum = dig_sum + VAL(SUBSTR(b_code,lop_e,1))
  109.         ENDIF
  110.       ENDDO
  111.       STORE  RIGHT(STR(dig_sum,5,0),1) TO un_dig
  112.       IF un_dig = "0"
  113.         b_code = b_code + "0"
  114.       ELSE
  115.         b_code = b_code + STR((10 - VAL(un_dig)),1,0)
  116.       ENDIF
  117.       STORE  LEN(b_code) TO lnb_code
  118.     ENDIF
  119.     IF pb_code
  120.       b_code = "[" + b_code + "]"
  121.       Replace &o_bc with b_code
  122.     ENDIF
  123.   ENDIF
  124.   SKIP
  125. ENDDO while .not.eof
  126.